<script lang="ts" setup>
import { useLocale } from '@/locale/locale';
import { useRouter } from '@/router';
import { onLoad } from '@dcloudio/uni-app';
import { ref } from 'vue';
import { getWithdrawDetail } from '@/api/user';
import { isWechat } from '@/utils/platform';

const { t } = useLocale();
const router = useRouter();
const info = ref();

async function getInfo(id: number) {
  const res = await getWithdrawDetail(id);
  if (res.code == 0) {
    info.value = res.data;
  }
}

onLoad(async (options) => {
  getInfo(options!.id);
});
</script>

<template>
  <uni-nav-bar
    v-if="isWechat()"
    :border="false"
    :title="t('LDKey_distributionDetail')"
    fixed
    left-icon="left"
    status-bar
    @click-left="router.back"
  />
  <view class="withdraw-detail-contain">
    <view class="withdraw-detail-contain-v">
      <image class="withdraw-detail-contain-v-top" src="/static/distribution/icon_withdraw.png" />
      <view class="withdraw-detail-contain-v-title">{{ t('LDKey_distributionWithdraw') }}</view>
      <view class="withdraw-detail-contain-v-price">
        <text class="withdraw-detail-contain-v-price-t1">¥</text>
        <text class="withdraw-detail-contain-v-price-t2">{{ info.withdrawAmount }}</text>
        <text class="withdraw-detail-contain-v-price-t3">JPY</text>
      </view>
      <view v-if="info.withdrawStatus == 'WAIT'" class="withdraw-detail-contain-v-status wait">
        {{ t('LDKey_distributionCommissionWithdrawing') }}
      </view>
      <view v-else-if="info.withdrawStatus == 'SUCCESS'" class="withdraw-detail-contain-v-status">
        {{ t('LDKey_distributionCommissionDetailWithdrawSuccess') }}
      </view>
      <view v-else-if="info.withdrawStatus == 'FAIL'" class="withdraw-detail-contain-v-status fail">
        {{ t('LDKey_distributionCommissionWithdrawFailed') }}
      </view>
      <view class="withdraw-detail-contain-v-list">
        <view class="withdraw-detail-contain-v-list-item">
          <view>{{ t('LDKey_distributionCommissionDetailCreateTime') }}</view>
          <view>{{ info.createdAt }}</view>
        </view>
        <view class="withdraw-detail-contain-v-list-item">
          <view>{{ t('LDKey_distributionCommissionDetailOrderAmount') }}</view>
          <view>{{ info.withdrawSn }}</view>
        </view>
        <view class="withdraw-detail-contain-v-list-item">
          <view>{{ t('LDKey_distributionCommissionDetailWithdrawAmount') }}</view>
          <view class="bold">¥{{ info.withdrawAmount }}JPY</view>
        </view>
        <view class="withdraw-detail-contain-v-list-item">
          <view>{{ t('LDKey_distributionCommissionDetailWithdrawFee') }}</view>
          <view class="bold">{{ info.serviceCharge }}%</view>
        </view>
        <view class="withdraw-detail-contain-v-list-item">
          <view>{{ t('LDKey_distributionCommissionDetailWithdrawArrivalAmount') }}</view>
          <view class="color">¥{{ info.arrivalAmount }}JPY</view>
        </view>
        <view class="withdraw-detail-contain-v-list-item1">
          <view class="withdraw-detail-contain-v-list-item1-title">
            {{ t('LDKey_distributionCommissionDetailWithdrawProgress') }}
          </view>
          <view class="withdraw-detail-contain-v-list-item1-cont">
            <view
              v-for="(item, index) in info.Schedule"
              :key="index"
              class="withdraw-detail-contain-v-list-item1-cont-step"
            >
              <view class="withdraw-detail-contain-v-list-item1-cont-step-t">
                <image src="/static/distribution/icon_step.png" />
                <view>{{ item.des }}</view>
              </view>
              <view class="withdraw-detail-contain-v-list-item1-cont-step-b">{{ item.time }}</view>
              <view
                v-if="index != info.Schedule.length - 1"
                class="withdraw-detail-contain-v-list-item1-cont-step-line"
              ></view>
            </view>
          </view>
        </view>
      </view>
    </view>
  </view>
</template>

<style lang="scss" scoped>
.withdraw-detail {
  &-contain {
    padding: 24rpx;

    &-v {
      background: #ffffff;
      border-radius: 20rpx;
      padding: 48rpx 32rpx 28rpx;

      &-top {
        display: block;
        width: 68rpx;
        height: 68rpx;
        margin: 0 auto;
      }

      &-title {
        margin-top: 22rpx;
        font-weight: 400;
        font-size: 28rpx;
        color: #3d3d3d;
        line-height: 40rpx;
        text-align: center;
      }

      &-price {
        margin-top: 28rpx;
        text-align: center;

        &-t1 {
          font-size: 28rpx;
          color: #3d3d3d;
          line-height: 32rpx;
        }

        &-t2 {
          font-size: 60rpx;
          color: #3d3d3d;
          line-height: 32rpx;
        }

        &-t3 {
          font-size: 24rpx;
          color: #3d3d3d;
          line-height: 32rpx;
        }
      }

      &-status {
        margin-top: 8rpx;
        font-weight: 400;
        font-size: 28rpx;
        color: #e87b15;
        line-height: 40rpx;
        text-align: center;

        &.wait {
          color: #269c74;
        }

        &.fail {
          color: #d13820;
        }
      }

      &-list {
        margin-top: 32rpx;

        &-item {
          display: flex;
          align-items: center;

          view {
            &:first-child {
              width: 150rpx;
              font-weight: 400;
              font-size: 28rpx;
              color: #adaeb0;
              line-height: 80rpx;
            }

            &:last-child {
              margin-left: 20rpx;
              font-weight: 400;
              font-size: 28rpx;
              color: #3d3d3d;
              line-height: 80rpx;

              &.bold {
                font-weight: 600;
              }

              &.color {
                color: #d13820;
              }
            }
          }
        }

        &-item1 {
          display: flex;

          &-title {
            width: 150rpx;
            font-weight: 400;
            font-size: 28rpx;
            color: #adaeb0;
            line-height: 80rpx;
          }

          &-cont {
            margin-left: 20rpx;
            margin-top: 26rpx;

            &-step {
              position: relative;
              padding-bottom: 32rpx;

              &-t {
                display: flex;
                align-items: center;

                image {
                  display: block;
                  width: 32rpx;
                  height: 32rpx;
                  margin-right: 24rpx;
                }

                view {
                  font-weight: 500;
                  font-size: 24rpx;
                  color: #3d3d3d;
                  line-height: 34rpx;
                }
              }

              &-b {
                margin-left: 56rpx;
                margin-top: 4rpx;
                font-weight: 400;
                font-size: 24rpx;
                color: #939393;
                line-height: 40rpx;
              }

              &-line {
                position: absolute;
                top: 30rpx;
                left: 13rpx;
                bottom: -4rpx;
                background: #4a86ff;
                width: 8rpx;
              }
            }
          }
        }
      }
    }
  }
}
</style>
